home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’97 / Animated Icons / Source / LIconSuitePane.cp < prev    next >
Encoding:
Text File  |  1997-06-23  |  2.6 KB  |  157 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. //    LIconPane.cp               ©1995-1996 Metrowerks Inc. All rights reserved.
  3. // ===========================================================================
  4. //
  5. //    Pane which draws a single icon from an icon family
  6.  
  7. #ifdef PowerPlant_PCH
  8. #include PowerPlant_PCH
  9. #endif
  10.  
  11. #include "LIconSuitePane.h"
  12. #include <LStream.h>
  13. #include <PP_Constants.h>
  14.  
  15. #ifndef __ICONS__
  16. #include <Icons.h>
  17. #endif
  18.  
  19.  
  20. LIconSuitePane*
  21. LIconSuitePane::CreateIconPaneStream(
  22.     LStream    *inStream)
  23. {
  24.     return (new LIconSuitePane(inStream));
  25. }
  26.  
  27.  
  28. LIconSuitePane::LIconSuitePane()
  29. {
  30.     mIconSuiteH = nil;
  31. }
  32.  
  33.  
  34. LIconSuitePane::LIconSuitePane(
  35.     const SPaneInfo        &inPaneInfo,
  36.     ResIDT                inIconID)
  37.         : LPane(inPaneInfo)
  38. {
  39.     InstallIconUtilitiesPatches ( );
  40.     
  41.     Debugger ();
  42.     
  43.     GetIconSuite ( & mIconSuiteH, inIconID, kSelectorAllAvailableData );
  44. }
  45.  
  46.  
  47. LIconSuitePane::LIconSuitePane(
  48.     LStream    *inStream)
  49.         : LPane(inStream)
  50. {    short iconID;
  51.     inStream->ReadData(&iconID, sizeof(ResIDT));
  52.     
  53.     InstallIconUtilitiesPatches ( );
  54.     
  55.     GetIconSuite ( & mIconSuiteH, iconID, kSelectorAllAvailableData );
  56. }
  57.  
  58.  
  59. LIconSuitePane::~LIconSuitePane()
  60. {
  61.     DisposeIconSuite ( mIconSuiteH, true );
  62. }
  63.  
  64.  
  65. void
  66. LIconSuitePane::SetIconID(
  67.     Handle iconSuite)
  68. {
  69.     if ( mIconSuiteH )
  70.         DisposeIconSuite ( mIconSuiteH, true );
  71.         
  72.     mIconSuiteH = iconSuite;
  73.     Refresh();
  74. }
  75.  
  76.  
  77. void
  78. LIconSuitePane::DrawSelf()
  79. {
  80.     Rect    frame;
  81.     CalcLocalFrameRect(frame);
  82.     
  83.     PlotIconSuite(&frame, atNone, ttNone, mIconSuiteH);
  84. }
  85.  
  86.  
  87. LIconRefPane*
  88. LIconRefPane::CreateIconRefPaneStream(
  89.     LStream    *inStream)
  90. {
  91.     return (new LIconRefPane(inStream));
  92. }
  93.  
  94.  
  95. LIconRefPane::LIconRefPane()
  96. {
  97.     mIconRef = nil;
  98. }
  99.  
  100.  
  101. LIconRefPane::LIconRefPane(
  102.     const SPaneInfo        &inPaneInfo,
  103.     ResIDT                inIconID)
  104.         : LPane(inPaneInfo)
  105. {
  106.     InstallIconServicesPatches ( );
  107.     
  108.     Debugger ();
  109.     
  110.     FSSpec spec;
  111.     
  112.     if ( FSMakeFSSpec ( 0, 0, "\pBasic PowerPlant 68k", & spec ) == noErr )
  113.         GetIconRefFromFileInfo ( & spec, & mIconRef, '\?\?\?\?', 'APPL', true );
  114. }
  115.  
  116.  
  117. LIconRefPane::LIconRefPane(
  118.     LStream    *inStream)
  119.         : LPane(inStream)
  120. {    short iconID;
  121.     inStream->ReadData(&iconID, sizeof(ResIDT));
  122.     
  123.     InstallIconServicesPatches ( );
  124.     
  125.     FSSpec spec;
  126.     
  127.     if ( FSMakeFSSpec ( 0, 0, "\pBasic PowerPlant 68k", & spec ) == noErr )
  128.         GetIconRefFromFileInfo ( & spec, & mIconRef, '\?\?\?\?', 'APPL', true );
  129. }
  130.  
  131.  
  132. LIconRefPane::~LIconRefPane()
  133. {
  134.     DisposeIconRef ( mIconRef );
  135. }
  136.  
  137.  
  138. void
  139. LIconRefPane::SetIconID(
  140.     IconRef iconRef )
  141. {
  142.     if ( mIconRef )
  143.         DisposeIconRef ( mIconRef );
  144.         
  145.     mIconRef = iconRef;
  146.     Refresh();
  147. }
  148.  
  149.  
  150. void
  151. LIconRefPane::DrawSelf()
  152. {
  153.     Rect    frame;
  154.     CalcLocalFrameRect(frame);
  155.     
  156.     PlotIconRef (&frame, atNone, ttNone, 0, mIconRef);
  157. }